<?php
require_once("../global.inc.php");

class SysAttributeContentManage extends SystemFrameWork{
	/**
	 * 商品对象
	 *
	 * @var obj
	 */
	var $obj_attribute_content;
	/**
	 * 验证对象
	 *
	 * @var obj
	 */
	var $objvalidate;

	function main(){
		
		/**
		 * 创建商品属性内容对象
		 */
		if (!is_object($this->obj_attribute_content)){
			require_once("attribute_content.class.php");
			$this->obj_attribute_content = new AttributeContentClass();
		}
		/**
		 * 创建验证对象
		 */
		if (!is_object($this->objvalidate)){
			require_once("commonvalidate.class.php");
			$this->objvalidate = new CommonValidate();
		}

		/**
		 * 设置模板路径
		 */
		$this->setsubtemplates("system");

		/**
		 * 语言包
		 */
		$this->getlang("attribute");

		switch ($this->_input['action']){
			case "list":
				$this->_listac();
				break;
			case "add":
				$this->_addac();
				break;
			case "update":
				$this->_updateac();
				break;
			case "del":
				$this->_delac();
				break;
			default:
				$this->_listac();
				break;
		}

	}
	/**
	 * 取得属性列表
	 */
	function _listac(){
		$a_id = $this->_input['aid'];
		$a_name = $this->_input['aname'];
		$attribute_content_array = $this->obj_attribute_content->getAttributeContentList($a_id);
		$this->output("a_id", $a_id);
		$this->output("a_name", $a_name);
		$this->output("attribute_content_array", $attribute_content_array);
		$this->showpage("sys_attributecontent.manage");
	}

	/**
	 * 添加商品分类的属性
	 *
	 */
	function _addac(){
		$this->objvalidate->validateparam = array(
		array("input"=>$this->_input["accontent"], "require"=>"true", "message"=>$this->_lang['errANameEmpty']),
		array("input"=>$this->_input["acorder"], "require"=>"true", "validator"=>"Number", "message"=>$this->_lang['errProductNameEmpty']));
		$error = $this->objvalidate->validate();

		if($error != ""){
			echo $error;
		}else{
			$result = $this->obj_attribute_content->addAttributeContent($this->_input);
			echo "ok";
		}
	}
	/**
	 * 更新商品分类的属性
	 * 
	 */
	function _updateac(){
		$this->objvalidate->validateparam = array(
		array("input"=>$this->_input["accontent"], "require"=>"true", "message"=>$this->_lang['errANameEmpty']),
		array("input"=>$this->_input["acorder"], "require"=>"true", "validator"=>"Number", "message"=>$this->_lang['errAOrder']));
		$error = $this->objvalidate->validate();

		if($error != ""){
			echo $error;
		}else{
			$result = $this->obj_attribute_content->updateAttributeContent($this->_input);
			echo "ok";
		}
	}
	/**
	 * 删除商品分类的属性
	 *
	 */
	function _delac(){
		$this->_input['txtDelACid'] = split(',',$this->_input['acid']);
		//print_r($this->_input['txtDelAid']);
		$result = $this->obj_attribute_content->delAttributeContent($this->_input['txtDelACid']);
		echo "ok";
	}

}

$attribute_content_manage = new SysAttributeContentManage();
$attribute_content_manage->main();
unset($attribute_content_manage);
?>